import React, { useState, useEffect } from 'react'
import { Col, Form, Input, Cascader } from 'antd'
import cityOptions from '@/utils/city'

// 省市区三级联调
const ProvincesCascader = props => {
  const { onChange, title, onlyCascader, } = props
  const setOptions = (citys) => {
    const opts = []
    citys.map(city => (
      city.children ?
      opts.push({
        label: city.label,
        value: city.code,
        children: setOptions(city.children)
      }) :
      opts.push({
        label: city.label,
        value: city.code,
      })
    ))
    return opts
  }
  return (
    <div>
      {
        <Cascader
          options={setOptions(cityOptions)}
          onChange={onChange}
          placeholder="请选择省市区"
          style={{width: '100%'}}
          {...props}
        />
      }
    </div>
  )
}

export default ProvincesCascader
